<script lang="ts" setup>
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { showToast} from "vant";

import Utils from "../../../req/Utils.js";
const router = useRouter();

const props = defineProps({
  obj: {
      type:Object
    }
});

const addCart = () => {
  showToast("添加商品成功")
  Utils.addCart(props.obj);
};
const toRoute = (str: any) => {
  router.push({path: str})
}

const toShop = ()=> {
   router.push({path: "/shopDetail",query: {shopId: props.obj.shopId}})
}
</script>

<template>
  <section class="productCartUtil">
      <div class="icons-wrap">
        <div class="item">
          <i class="say"></i>
          <span class="text">联系客服</span>
        </div>
        <div class="item" @click="toShop()">
          <i class="entry"></i>
          <span class="text">进店</span>
        </div>
        <div class="item">
          <i class="cart"></i>
          <span class="text" @click="toRoute('/cart')">购物车</span>
        </div>
      </div>
      <div class="btn add" @click="addCart()">加入购物车</div>
      <div class="btn buy" @click="toRoute('/cart')">立即购买</div>
  </section>
</template>

<style lang="less" scoped>
.productCartUtil {
  width: 3.75rem;
  height: .5rem;
  background: white;
  display: flex;
  position: relative;
  &::after {
    width: 100%;
    height: 0rem;
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    border-top: 1px solid #ddd;
  }
  .icons-wrap {
    flex: 1;
    display: flex;
    .item {
      width: 33%;
      height: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      i {
        width: .2rem;
        height: .25rem;
        background-size: contain !important;
      }
      .say {
        background: url("../../../assets/images/call-icon-1.png") no-repeat center;
      }
      .entry {
        background: url("../../../assets/images/shop-icon-1.png") no-repeat center;
      }
      .cart {
        background: url("../../../assets/images/cart-icon-7.png") no-repeat center;
      }
      .text {
        font-size: .1rem;
        color: #666;
      }
    }
  }
  .btn {
    width: 1.08rem;
    height: .5rem;
    line-height: .5rem;
    text-align: center;
    color: #fff;
    font-size: .14rem;
    &.add {
      background: #ff9600;
    }
    &.buy {
      background: #e4393c;
    }
  }
  
}
</style>

